<template>
	<div>
		<div v-bind="props">{{ a + b }}</div>
		<input v-bind="attrs" type="text" @input="callback" />
		<slot name="title">123</slot>

		<!-- 判断是否存在插槽 -->
		<div v-if="$slots.name">
			<slot name="name"></slot>
		</div>
	</div>
</template>

<script setup lang="ts">
import { onMounted, useAttrs } from 'vue'
defineOptions({
	inheritAttrs: false,
})
const props = defineProps(['a', 'b'])
const attrs = useAttrs()
const emit = defineEmits(['input'])

const callback = (e: any) => {
	emit('input', e)
}

onMounted(() => {
	console.log(attrs) // 除了props接受的其余 包括 id class style，包括自定义事件（v2需要用listeners接收自定义事件）
})
</script>
